import axios from 'axios';

import {ElMessage} from 'element-plus'
const baseURL = 'http://localhost:9090';
const instance = axios.create({baseURL});


instance.interceptors.response.use(
    result=>{
        if (result.data.code===20000) {
            return result.data;
        }
        ElMessage.error(result.data.message?result.data.message:"操作失败")
        return Promise.reject(result.data);
    },
    err=>{
        ElMessage.error("服务异常");
        return Promise.reject(err);
    }
)

export default instance;